//有缓冲的通道
package main

import (
	"fmt"
	"sync"
)

const (
	totalWorks  = 10
	maxRoutines = 4
)

var wg2 sync.WaitGroup

func RunChannel2() {
	tasks := make(chan string, totalWorks)

	wg2.Add(maxRoutines)

	for i := 0; i < maxRoutines; i++ {
		go worker(tasks)
	}
	for i := 0; i < totalWorks; i++ {
		tasks <- fmt.Sprintf("Task %d", i)
	}

	wg2.Wait()

	var baton = make(chan int)
	wg2.Add(1)
	go Runner(baton)
	baton <- 1
	wg2.Wait()
}
func worker(tasks chan int) {
	defer wg2.Done()
	job := <-tasks

}
